package com.itheima.mapper;

import com.itheima.pojo.Emp;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.RequestBody;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface EmpMapper {
    //员工的Mapper接口

    //查询员工数量
   /* @Select("select count(*) from emp")
    Integer count();*/

    //查询员工分页列表
    /*@Select("select * from emp limit #{page},#{pageSize}")
    List<Emp> page(@Param("page") Integer page,@Param("pageSize") Integer pageSize);*/
//    @Select("select * from emp")
    //动态sql查询员工分页列表
    List<Emp> page(@Param("name") String name, @Param("gender") Short gender, @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    //动态sql 批量删除员工
    void delete(@Param("ids") List<Integer> ids);

    //添加员工
    void insert(Emp emp);

    //根据id查询员工
    @Select("select * from emp where id = #{id}")
    Emp getById(Integer id);

    //根据id更新员工信息
    void update(Emp emp);

    //根据登录信息查询员工
    @Select("select * from emp where username = #{username} and password = #{password}")
    Emp getByLoginInfo(Emp emp);

    //根据部门id删除员工
    @Delete("delete from emp where dept_id = #{id}")
    void deleteByDeptId(@Param("id") int id);
}
